/**
 * Copyright (C) 2013 SHANGHAI VOLKSWAGEN, All rights reserved.
 * License version 1.0, a copy of which has been included with this.
 *
 * @File name：com.market.coupon.server.strategy.FullMinusCoupon
 * @Create on：2024/3/4
 * @Author：liuchang
 */
package com.market.coupon.server.strategy;

import com.market.coupon.common.domain.Req.ComputerReq;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * <p>ClassName：FullMinusCoupon</p >
 * <p>Description：</p >
 * <p>Author：liuchang</p >
 * <p>Date：2024/3/4</p >
 */
@Component
public class FullMinusCoupon implements CouponStrategy{
    @Override
    public BigDecimal doActive(ComputerReq computerReq) {
        //判断是否满足优惠券使用条件
        int i = computerReq.getOrderPrice().compareTo(computerReq.getMinOrderAmount());
        if (i<0) {
            return computerReq.getOrderPrice();
        }
        //返回最终价格
        BigDecimal orderPrice = computerReq.getOrderPrice().subtract(computerReq.getDiscountAmount());
        return orderPrice;
    }
}
